/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package medico;

import com.mysql.jdbc.Statement;
import connezione.PooledConnection;
import java.io.Serializable;
import java.sql.SQLException;
import javax.faces.context.FacesContext;
import login.BeanUser;

/**
 *
 * @author sestari
 */
public class BeanForminserire_paziente implements Serializable {

    private String username;
    private String password;
    BeanMedico medico;
    PooledConnection conn;

    /** Creates a new instance of BeanForminserire_paziente */
    public BeanForminserire_paziente() {
        medico = ((BeanMedico) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("beanMedico"));
        conn = (PooledConnection) ((BeanUser) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("user")).getCon();
    }

    public String inserirePazeinte() throws SQLException {
        Statement stmt = (Statement) conn.createStatement();
        String command;

        command = "INSERT INTO `db_user15`.`Utenti` (`id_persona`,`username`,`password`,`id_medico`,`tipo_persona`) ";
        command += " VALUES (\"" + medico.getIdpaziente() + "\", \"" + getUsername() + "\", \"" + getPassword() + "\", \"" + medico.getIdmedico() + "\", \"PAZIENTE\") ";

        stmt.executeUpdate(command);



        return "foto";
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
